<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<form>
    <input type="text" name="name">
    <input type="button" value="Search" th:onclick="doFindBrand()" class="btn btn-primary">
    <input type="button" value="Add" th:onclick="doAddUI()" class="btn btn-info">
</form>
    <table class="table">
        <thead>
            <tr>
                <td>id</td>
                <td>name</td>
                <td>remark</td>
                <td>createdTime</td>
                <td>操作</td>
            </tr>
        </thead>
        <tbody>
            <tr th:each="list:${list}">
                <td th:text="${list.id}"></td>
                <td th:text="${list.name}"></td>
                <td th:text="${list.remark}"></td>
                <td th:text="${#dates.format(list.createdTime, 'yyyy/MM/dd HH:mm')}"></td>
                <td>
                    <button type="button" th:onclick="doDeleteById([[${list.id}]])" class="btn btn-danger btn-xs">Delete</button>
                    <button type="button" th:onclick="doFindById([[${list.id}]])" class="btn btn-warning btn-xs">Update</button>
                </td>
            </tr>
        </tbody>
    </table>
</div>
<script>
    function doFindBrand(){
        let name=document.forms[0].name.value;
        location.href=`http://localhost:8080/brand/doFindBrands/${name}`
    }
    function doDeleteById(id){
        location.href=`http://localhost:8080/brand/doDeleteById/${id}`
    }
    function doAddUI(){
        location.href=`http://localhost:8080/brand/doAddUI`
    }
    function doFindById(id){
        location.href=`http://localhost:8080/brand/doFindById/${id}`
    }
</script>
</body>
</html>